<template>
  <div class="app-container">
    <cus-wraper>
      <cus-filter-wraper>
        <div>
<!--          <el-select filterable v-model="flagIndex" @change="reflag" class="filter-item" placeholder='请选择' style="width: 200px;">-->
<!--            <el-option v-for="item in flagList" :key="item.key" :label="item.lab" :value="item.key"></el-option>-->
<!--          </el-select>-->
          <el-input v-model="listQuery.id" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入ID" style="width:200px;margin: 0 10px 10px 0;" clearable></el-input>
          <el-input v-model="listQuery.skillName" onkeyup="value=value.replace(/[^\d]/g,'')" placeholder="请输入名称" style="width:200px;margin: 0 10px 10px 0;" clearable></el-input>
          <el-select filterable v-model="listQuery.groupId" placeholder="请选择分组" style="width: 200px;margin: 0 10px 10px 0;">
            <el-option v-for="item in this.skillGroup" :key="item.id" :label="item.groupName" :value="item.id"></el-option>
          </el-select>
          <el-select filterable v-model="listQuery.skillSwitch" class="filter-item" placeholder='请选择是否禁用' style="width: 200px;margin: 0 10px 10px 0;">
            <el-option v-for="item in flagList2" :key="item.key" :label="item.lab" :value="item.key"></el-option>
          </el-select>
          <el-button type="primary" @click="search" icon="el-icon-search">查询</el-button>
          <el-button type="info" @click="reGetList" icon="el-icon-search">重置</el-button>
        </div>
        <el-button type="primary" @click="handleCreate" icon="el-icon-search" style="max-height: 36px;">创建</el-button></cus-filter-wraper>
      <div class="table-container">
        <el-table v-loading="listLoading" :data="list" style="width: 100%" ref="itsmDataTable" size="mini" fit element-loading-text="Loading" highlight-current-row align="center">
          <el-table-column label="id" prop="id" align="center"></el-table-column>
          <el-table-column label="分组" prop="groupId" align="center">
            <template slot-scope="scope">
              {{ skillGroupMessage(scope.row.groupId) }}
            </template>
          </el-table-column>
          <el-table-column label="名称" prop="skillName" align="center"></el-table-column>
          <el-table-column label="等级截图提示" prop="skillRemark" align="center"></el-table-column>
          <el-table-column label="资质图标" prop="skillPicture" align="center">
            <template slot-scope="scope">
              <span>
                <img :src="scope.row.skillPicture" alt="" style="width: 50px;">
              </span>
            </template>
          </el-table-column>
          <el-table-column label="声音提示" prop="voiceRemark" align="center"></el-table-column>

          <el-table-column label="资质等级示例" prop="examPicture" align="center">
            <template slot-scope="scope">
              <span>
                <img :src="scope.row.examPicture" alt="" style="width: 50px;">
              </span>
            </template>
          </el-table-column>
          <el-table-column label="单位" prop="skillUnit" align="center">
            <template slot-scope="scope">
              {{ reversedMessage(scope.row.skillUnit) }}
            </template>
          </el-table-column>
          <el-table-column label="是否禁用" prop="skillSwitch" align="center">
            <template slot-scope="scope">
              <el-button type="success" round v-if="scope.row.skillSwitch === 1">已启用</el-button>
              <el-button type="danger" round v-else>已禁用</el-button>
            </template>
          </el-table-column>
          <el-table-column label="排序" prop="skillOrder" align="center"></el-table-column>

            <el-table-column align="center" width="300px" v-if="this.global_checkBtnPermission(['sys:user:edit','sys:user:delete'])" label="操作">
            <template slot-scope="scope">
              <el-button  size="mini" type="primary" @click="getBySkillId(scope.row.id)" icon="el-icon-edit" plain>
                查看
              </el-button>
              <el-button  size="mini" type="primary" @click="handleUpdate(scope.row)" icon="el-icon-edit" plain>
                修改
              </el-button>
              <cus-del-btn  @ok="handleDelete(scope.row)"/>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <cus-pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList"/>
      </div>

      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogVisible" width="40%" v-dialogDrag @close="handleDialogClose">
        <el-form ref="dataForm" :model="form" :rules="rules" label-width="120px" class="demo-ruleForm">
          <el-form-item label="分组:" prop="groupId">
            <el-select filterable v-model="form.groupId" placeholder="请选择">
              <el-option
                v-for="item in this.skillGroup"
                :key="item.id"
                :label="item.groupName"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="名称:" prop="skillName">
            <el-input v-model="form.skillName"></el-input>
          </el-form-item>
          <el-form-item label="等级截图提示:" prop="skillRemark">
            <el-input v-model="form.skillRemark"></el-input>
          </el-form-item>
          <el-form-item label="资质等级示例:" prop="examPicture">
            <el-upload
              action=""
              ref="upload"
              :http-request="Upload2"
              :auto-upload="true"
              list-type="picture-card"
              :on-change="handleLimit2"
              :on-remove="handleRemove2"
              :limit="1"
              :class="{disabled:uploadDisabled2}"
              :style="{display:form.examPicture?'none':'block'}"
            >
              <i class="el-icon-plus" />
            </el-upload>
            <img class="uploadImg" :src="form.examPicture" :style="{display:form.examPicture?'block':'none'}" alt="">
            <el-button type="primary" @click="reload2(1)" class="reload" :style="{display:form.examPicture?'block':'none'}">重新上传</el-button>
          </el-form-item>
          <el-form-item label="资质图标:" prop="skillPicture">
            <el-upload
              action=""
              ref="upload"
              :http-request="Upload"
              :auto-upload="true"
              list-type="picture-card"
              :on-change="handleLimit"
              :on-remove="handleRemove"
              :limit="1"
              :class="{disabled:uploadDisabled}"
              :style="{display:form.skillPicture?'none':'block'}"
            >
              <i class="el-icon-plus" />
            </el-upload>
            <img class="uploadImg" :src="form.skillPicture" :style="{display:form.skillPicture?'block':'none'}" alt="">
            <el-button type="primary" @click="reload(1)" class="reload" :style="{display:form.skillPicture?'block':'none'}">重新上传</el-button>
          </el-form-item>
          <el-form-item label="声音提示:" prop="voiceRemark">
            <el-input v-model="form.voiceRemark"></el-input>
          </el-form-item>

          <el-form-item label="单位:" prop="skillUnit">
            <el-select filterable v-model="form.skillUnit" placeholder="请选择">
              <el-option
                v-for="item in this.dictionariesList"
                :key="item.id"
                :label="item.company"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="示例声音:" prop="examples">
            <div v-if="dialogStatus === 'update'">
              <el-input v-for="i in form.examples" v-model="i.value" style="width: 200px;" :key="i.value" disabled></el-input>
            </div>
            <div v-else>
              <div style="margin-bottom: 10px;">
                <el-input v-model="addDomainInput3" style="width: 200px;"></el-input>
                <el-button type="primary" @click="addDomain3(addDomainInput3)">新增</el-button>
              </div>
              <div v-for="i in form.examples" :key="i.key" style="margin-bottom: 10px;">
                <el-input v-model="i.value" style="width: 200px;"></el-input>
                <el-button type="danger"  @click.prevent="removeDomain3(i)">删除</el-button>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="技能资质要求:" prop="wordsRemarks">
            <div v-if="dialogStatus === 'update'">
              <el-input v-for="i in form.wordsRemarks" v-model="i.value" style="width: 200px;" :key="i.value" disabled></el-input>
            </div>
            <div v-else>
              <div style="margin-bottom: 10px;">
                <el-input v-model="addDomainInput2" style="width: 200px;"></el-input>
                <el-button type="primary" @click="addDomain2(addDomainInput2)">新增</el-button>
              </div>
              <div v-for="i in form.wordsRemarks" :key="i.key" style="margin-bottom: 10px;">
                <el-input v-model="i.value" style="width: 200px;"></el-input>
                <el-button type="danger"  @click.prevent="removeDomain2(i)">删除</el-button>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="价格:" prop="prices">
            <div v-if="dialogStatus === 'update'">
              <el-input v-for="i in form.prices"  onkeyup="value=value.replace(/[^\d]/g,'')" v-model="i.value" :key="i.value" style="width: 200px;" disabled></el-input>
            </div>
            <div v-else>
              <div style="margin-bottom: 10px;">
                <el-input v-model="addDomainInput1" style="width: 200px;"></el-input>
                <el-button type="primary" @click="addDomain(addDomainInput1)">新增</el-button>
              </div>
              <div v-for="i in form.prices" :key="i.key" style="margin-bottom: 10px;">
                <el-input v-model="i.value" style="width: 200px;"></el-input>
                <el-button type="danger"  @click.prevent="removeDomain(i)">删除</el-button>
              </div>
            </div>
          </el-form-item>
          <el-form-item label="必填游戏ID:" >
            <el-radio v-model="form.isMust" :label=0>不必须</el-radio>
            <el-radio v-model="form.isMust" :label=1>必须</el-radio>
          </el-form-item>
          <el-form-item label="接单间隔时间:" >
            <el-input-number v-model="form.intervalTime" @change="handleChange" :min="0" :max="1000" label="排序"></el-input-number><span>(分钟)</span>
          </el-form-item>
          <el-form-item label="是否禁用:" prop="skillSwitch">
            <el-select filterable v-model="form.skillSwitch" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="排序:" prop="skillOrder">
            <el-input-number v-model="form.skillOrder" @change="handleChange" :min="1" :max="1000" label="排序"></el-input-number>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false"> 取 消 </el-button>
          <el-button type="primary" @click="submitForm"> 确 认 </el-button>
        </span>
      </el-dialog>

      <el-dialog title="修改" :visible.sync="dialogCenter" width="40%" v-dialogDrag @close="handleDialogClose">
        <el-form ref="dataForm" :model="form" :rules="rules" label-width="120px" class="demo-ruleForm">
            名称:{{form.skillName}}
          <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" style="margin-bottom: 10px;" @select="handleSelect">
            <el-menu-item index="1">示例声音</el-menu-item>
            <el-menu-item index="2">技能资质要求</el-menu-item>
            <el-menu-item index="3">价格</el-menu-item>
          </el-menu>
          <div v-if="selectCon === '1'">
            <div><el-input v-model="addtableInput1" style="width: 200px;margin-right:10px;"></el-input><el-button type="primary" @click="addtableDataCon1">新增</el-button></div>
            <el-table :data="tableDataCon1" style="width: 100%;margin-top: 10px;">
              <el-table-column prop="id" label="id"></el-table-column>
              <el-table-column prop="example" label="值"></el-table-column>
              <el-table-column width="300px" label="操作">
                <template slot-scope="scope">
                  <el-button type="primary"  @click.prevent="removetableDataCon1(scope.row.id)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <cus-pagination v-show="totalCon1>0" :total="totalCon1" :page.sync="listQueryCon1.page" :limit.sync="listQueryCon1.pageSize" @pagination="getskillVoicePage"/>
          </div>
          <div v-if="selectCon === '2'">
            <div><el-input v-model="addtableInput2" style="width: 200px;margin-right:10px;"></el-input><el-button type="primary" @click="addtableDataCon2">新增</el-button></div>
            <el-table :data="tableDataCon2" style="width: 100%;margin-top: 10px;">
              <el-table-column prop="id" label="id"></el-table-column>
              <el-table-column prop="wordsRemark" label="值"></el-table-column>
              <el-table-column width="300px" label="操作">
                <template slot-scope="scope">
                  <el-button type="primary"  @click.prevent="removetableDataCon2(scope.row.id)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <cus-pagination v-show="totalCon2>0" :total="totalCon2" :page.sync="listQueryCon2.page" :limit.sync="listQueryCon2.pageSize" @pagination="getwordsRemarkPage"/>
          </div>
          <div v-if="selectCon === '3'">
            <div><el-input v-model="addtableInput3" style="width: 200px;margin-right:10px;"></el-input><el-button type="primary" @click="addtableDataCon3">新增</el-button></div>
            <el-table :data="tableDataCon3" style="width: 100%;margin-top: 10px;">
              <el-table-column prop="id" label="id"></el-table-column>
              <el-table-column prop="price" label="值"></el-table-column>
              <el-table-column width="300px" label="操作">
                <template slot-scope="scope">
                  <el-button type="primary"  @click.prevent="removetableDataCon3(scope.row.id)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <cus-pagination v-show="totalCon3>0" :total="totalCon3" :page.sync="listQueryCon3.page" :limit.sync="listQueryCon3.pageSize" @pagination="getPriceConfigPage"/>
          </div>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogCenter = false"> 取 消 </el-button>
          <el-button type="primary" @click="submitForm2"> 确 认 </el-button>
        </span>
      </el-dialog>


    </cus-wraper>
  </div>
</template>

<script>
  import { getSysUserPage, addSkillGroup, deleteSysUser, getskillGroup,
          getdictionariesGroup, getBySkillId,
    getPriceConfigPage, addPriceConfigGroup, deletePriceConfig,
    getskillVoicePage, addskillVoiceGroup, deleteskillVoice,
    getwordsRemarkPage, addwordsRemarkGroup, deleteswordsRemark
  } from '@/api/qualification/skillConfig'
  import { client } from '@/utils/ali-oss'

  export default {
    data() {
      return {
        dialogVisible: false,
        dialogCenter:false,
        activeIndex:'1',
        selectCon:'1',
        list: [],
        dictionariesList: [],
        skillGroup: [],
        listLoading: true,
        total: 0,
        listQuery: {
          page: 1,
          pageSize: 10,
          id: undefined,
          groupId: undefined,
          skillName: undefined,
          skillSwitch: undefined,
        },
        flagList: [{ key: '1', lab: 'id' },{ key: '2', lab: '分组' },{ key: '3', lab: '名称' }, { key: '4', lab: '审核状态' }],
        flagList2: [{ key: '1', lab: '启用' }, { key: '0', lab: '禁用' } ],
        flagIndex:'1',
        flagText:'',
        flagText2:undefined,
        flagText3:undefined,
        totalCon1: 0,
        listQueryCon1: {
          page: 1,
          pageSize: 10,
        },
        totalCon2: 0,
        listQueryCon2: {
          page: 1,
          pageSize: 10,
        },
        totalCon3: 0,
        listQueryCon3: {
          page: 1,
          pageSize: 10,
        },
        form: {
          id: undefined, //主键ID
          groupId:'',
          skillName:'',
          skillRemark:'',
          skillPicture:'',
          examPicture:'',
          voiceRemark:'',
          skillUnit:'',
          wordsRemarks: [],
          prices: [],
          examples:[],
          skillOrder: 1, //账号
          skillSwitch: 1, //账号
          isMust: 0, //账号
          intervalTime: 0, //账号
        },
        addDomainInput1: '',
        addDomainInput2:'',
        addDomainInput3:'',
        dialogStatus: '',
        titleMap: {
          update: '编辑技能',
          create: '创建技能'
        },

        dialogVisibleImg1: false,
        uploadDisabled:false,
        uploadDisabled2:false,
        options: [{
          value: 1,
          label: '启用'
        }, {
          value: 0,
          label: '禁用'
        }],
        changeValue: 1,
        searchVal: '',

        rules: {
          groupId: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          skillName: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          skillRemark: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          voiceRemark: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          skillUnit: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          skillSwitch: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          skillOrder: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
          prices: [
            {required: true, message: '请输入', trigger: 'blur'},
          ],
        },

        tableDataCon1:[],
        tableDataCon2:[],
        tableDataCon3:[],
        addtableInput1:'',
        addtableInput2:'',
        addtableInput3:'',
        skillId:'',
        skillGroupId:'',
      }
    },
    created() {
      this.getList()
      this.getDictionariesList()  //单位
      this.getSkillGroupList()  //组别
    },
    computed: {
      skillGroupMessage: function (val) {
        const getAge = val => (this.skillGroup.find(value => (value.id === val)).groupName);
        return getAge
      },
    },
    methods: {
      reversedMessage: function (val) {
        let company = ''
        for(let i of this.dictionariesList){
          if(i.id===val){company = i.company }
        }
        return company
      },
      getList() {
        this.listLoading = true;
        getSysUserPage(this.listQuery).then(response => {
          let data = response.data.records
          let arr1 = [], arr2 = [], arr3=[]
          if(data.wordsRemarks){
            for(let i of data.wordsRemarks){
              arr1.push({
                value: i,
                key: Date.now()
              });
            }
          }
          if(data.prices){
            for(let j of data.prices){
              arr2.push({
                value: j,
                key: Date.now()
              });
            }
          }
          if(data.examples){
            for(let k of data.examples){
              arr3.push({
                value: k,
                key: Date.now()
              });
            }
          }
          data.wordsRemarks = arr1
          data.prices = arr2
          data.examples = arr3
          // data)
          this.list = data;
          this.total = response.data.total;
          this.listLoading = false;
        })
      },
      getBySkillId(id){
        getBySkillId(id).then(response => {
          let data = response.data
          let arr1 = [], arr2 = [], arr3=[]
          if(data.wordsRemarks){
            for(let i of data.wordsRemarks){
              arr1.push({
                value: i,
                key: Date.now()
              });
            }
          }
          if(data.prices){
            for(let j of data.prices){
              arr2.push({
                value: j,
                key: Date.now()
              });
            }
          }
          if(data.examples){
            for(let k of data.examples){
              arr3.push({
                value: k,
                key: Date.now()
              });
            }
          }
          data.wordsRemarks = arr1
          data.prices = arr2
          data.examples = arr3

          this.form = data;
          this.dialogStatus = 'update';
          this.dialogVisible = true
          this.listLoading = false;
        })
      },
      getDictionariesList() {
        getdictionariesGroup().then(response => {

          this.dictionariesList = response.data;
        })
      },
      getSkillGroupList() {
        getskillGroup().then(response => {

          this.skillGroup = response.data;
        })
      },
      search(){
        // this.listQuery= {page: 1,pageSize: 10,}
        // if(this.flagIndex === '1'){
        //   this.listQuery.id = this.searchVal;
        // }else if(this.flagIndex === '2'){
        //   this.listQuery.groupId = this.flagText3;
        // }else if(this.flagIndex === '3'){
        //   this.listQuery.skillName = this.searchVal;
        // }else if(this.flagIndex === '4'){
        //   this.listQuery.skillSwitch = this.flagText2;
        // }
        // this.listQuery)
        this.getList();
      },
      reflag(){},
      reGetList(){
        this.listQuery.id= undefined
        this.listQuery.groupId= undefined
        this.listQuery.skillName= undefined
        this.listQuery.skillSwitch= undefined
        this.getList();
      },
      handleCreate() {
        this.resetForm()
        this.dialogStatus = 'create';
        this.dialogVisible = true
      },
      handleUpdate(data) {
        this.dialogCenter = true
        this.listLoading = false;
        this.getwordsRemarkPage(data.id)
        this.getskillVoicePage(data.id)
        this.getPriceConfigPage(data.id)
        this.skillId = data.id
        this.skillGroupId = data.groupId
      },
      handleDelete(row) {
        let id = row.id
        deleteSysUser(id).then(response => {
          if (response.code === 0) {
            this.getList();
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },
      submitForm() {
        let data = JSON.parse(JSON.stringify(this.form))
        let arr1 = [], arr2 = [], arr3 = []

        if(data.wordsRemarks.length ===1 && data.wordsRemarks[0].value ===''){}else{
          for(let i of data.wordsRemarks){
            if(i.value !== ''){arr1.push(i.value);}
          }
        }
        if(data.prices.length ===1 && data.prices[0].value ===''){}else{
          for(let i of data.prices){
            if(i.value !== ''){arr2.push(i.value);}
          }
        }
        if(data.examples.length ===1 && data.examples[0].value ===''){}else{
          for(let i of data.examples){
            if(i.value !== ''){arr3.push(i.value);}
          }
        }

        data.wordsRemarks = arr1
        data.prices = arr2
        data.examples = arr3

        // return
        this.$refs.dataForm.validate(valid => {
          if (valid) {
            addSkillGroup(data).then(response => {
              if (response.code === 0) {
                this.getList();
                this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });;
                this.dialogVisible = false
              } else {
                this.$message({
                message: response.message,
                type: 'error'
            });
              }
            }).catch(err => {

            })
          }
        })
      },
      resetForm() {
        this.form = {
          id: undefined, //主键ID
          groupId:'',
          skillName:'',
          skillRemark:'',
          skillPicture:'',
          examPicture:'',
          voiceRemark:'',
          skillUnit:'',
          wordsRemarks: [],
          prices: [],
          examples:[],
          skillOrder: 1, //账号
          skillSwitch: 1, //账号
          isMust: 0, //账号
          intervalTime: 0, //账号
        }
        if(this.$refs.upload){
          this.$refs.upload.clearFiles();
        }
        if(this.$refs.upload2){
          this.$refs.upload2.clearFiles();
        }
        this.uploadDisabled = false;
        this.uploadDisabled2 = false;
        this.addDomainInput1 = '';
        this.addDomainInput2 = '';
        this.addDomainInput3 = '';
      },
      // 监听dialog关闭时的处理事件
      handleDialogClose() {
        this.resetForm();

        if (this.$refs['dataForm']) {
          this.$refs['dataForm'].clearValidate() // 清除整个表单的校验
        }
      },
      toggleSelection(){
        // 一键删除
        const _selectData = this.$refs.itsmDataTable.selection;
        if(_selectData.length === 0){return}
        let selectArry = [];
        _selectData.map(row => {
          selectArry.push(row.id)
        });

        deleteSysUser(selectArry).then(response => {
          if (response.code === 0) {
            this.getList();
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },

      // 上传图片
      Upload(file) {
        const that = this;
        const names = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']
        if (!names.includes(file.file.type)) {this.$message.error('不支持的格式!'); return }
        const fileName = Date.now() + '-' + file.file.name;
        client().put(fileName, file.file,).then(result => {
          that.form.skillPicture = result.url
        }).catch(err => {

        })
      },
      // 删除图片
      handleRemove(fileList) {
        this.form.skillPicture = '';
        this.uploadDisabled = fileList.length>=1
      },
      handleLimit(file,fileList){
        this.uploadDisabled = fileList.length>=1
      },

      reload(val){
        this.form.skillPicture = '';
        this.uploadDisabled = false;
        this.$refs.upload.clearFiles();
      },

      // 上传图片2
      Upload2(file) {
        const that = this;
        const names = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']
        if (!names.includes(file.file.type)) {this.$message.error('不支持的格式!'); return }
        const fileName = Date.now() + '-' + file.file.name;
        client().put(fileName, file.file,).then(result => {
          that.form.examPicture = result.url
        }).catch(err => {

        })
      },
      // 删除图片2
      handleRemove2(fileList) {
        this.form.examPicture = '';
        this.uploadDisabled2 = fileList.length>=1
      },
      handleLimit2(file,fileList){
        this.uploadDisabled2 = fileList.length>=1
      },

      reload2(val){
        this.form.examPicture = '';
        this.uploadDisabled2 = false;
        this.$refs.upload.clearFiles();
      },

      handleChange(value) {

      },
      addDomain(val){
        this.form.prices.push({
          value: val,
          key: Date.now()
        });
        this.addDomainInput1 = ''
      },
      removeDomain(item){
        let index = this.form.prices.indexOf(item)
        if (index !== -1) {
          this.form.prices.splice(index, 1)
        }
      },
      addDomain2(val){
        this.form.wordsRemarks.push({
          value: val,
          key: Date.now()
        });
        this.addDomainInput2 = ''
      },
      removeDomain2(item){
        let index = this.form.wordsRemarks.indexOf(item)
        if (index !== -1) {
          this.form.wordsRemarks.splice(index, 1)
        }
      },
      addDomain3(val){
        this.form.examples.push({
          value: val,
          key: Date.now()
        });
        this.addDomainInput3 = ''
      },
      removeDomain3(item){
        let index = this.form.examples.indexOf(item)
        if (index !== -1) {
          this.form.examples.splice(index, 1)
        }
      },
      handleSelect(key, keyPath) {
        // key, keyPath);
        this.selectCon = key
      },
      submitForm2(){
        let arr1 = [], arr2 = [], arr3 = []
        if(this.selectCon === '1'){
          // this.form.examples)
          for(let i of this.form.examples){
            if(i.value !== ''){arr1.push(i.value);}
          }
        }else if(this.selectCon === '2'){
          // this.form.wordsRemarks)
          for(let i of this.form.wordsRemarks){
            if(i.value !== ''){arr1.push(i.value);}
          }
        }else if(this.selectCon === '3'){
          // this.form.prices)
          for(let i of this.form.prices){
            if(i.value !== ''){arr1.push(i.value);}
          }
        }
      },


      // 声音
      getskillVoicePage(id){
        this.listQueryCon1.skillId = id
        getskillVoicePage(this.listQueryCon1).then(response => {
          this.tableDataCon1 = response.data.records;
          this.totalCon1 = response.data.total;
        })
      },
      addtableDataCon1(){
        let data = { "groupId": this.skillGroupId,"skillId": this.skillId, "example": this.addtableInput1,"isDisable": 0 }
        addskillVoiceGroup(data).then(response => {
          if (response.code === 0) {
            this.getskillVoicePage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },
      removetableDataCon1(id){
        deleteskillVoice(id).then(response => {
          if (response.code === 0) {
            this.getskillVoicePage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },

      //技能
      getwordsRemarkPage(id){
        this.listQueryCon2.skillId = id
        getwordsRemarkPage(this.listQueryCon1).then(response => {
          this.tableDataCon2 = response.data.records;
          this.totalCon2 = response.data.total;
        })
      },
      addtableDataCon2(){
        let data = { "groupId": this.skillGroupId,"skillId": this.skillId, "wordsRemark": this.addtableInput2,"isDisable": 0 }
        addwordsRemarkGroup(data).then(response => {
          if (response.code === 0) {
            this.getwordsRemarkPage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },
      removetableDataCon2(id){
        deleteswordsRemark(id).then(response => {
          if (response.code === 0) {
            this.getwordsRemarkPage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },

      //价格
      getPriceConfigPage(id){
        this.listQueryCon3.skillId = id
        getPriceConfigPage(this.listQueryCon1).then(response => {
          this.tableDataCon3 = response.data.records;
          this.totalCon3 = response.data.total;
        })
      },
      addtableDataCon3(){
        let data = { "groupId": this.skillGroupId,"skillId": this.skillId, "price": this.addtableInput3,"isDisable": 0 }
        addPriceConfigGroup(data).then(response => {
          if (response.code === 0) {
            this.getPriceConfigPage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },
      removetableDataCon3(id){
        // let data = { "skillId": this.skillId, "id": this.id }
        deletePriceConfig(id).then(response => {
          if (response.code === 0) {
            this.getPriceConfigPage(this.skillId);
            this.$notify({
                    type:'success',
                    message: '操作成功',
                    position: 'bottom-right',
                    showClose: false,
                    duration: 3000
                });
          }
        })
      },

    }
  }
</script>
<style lang="scss" scoped>
  // .el-upload--picture-card 控制加号部分
  .disabled /deep/ .el-upload--picture-card {
    display: none;
  }
  .disabled2 /deep/ .el-upload--picture-card {
    display: none;
  }
  .uploadImg, .uploadImg2{
    width:148px;
    height: 148px;
    border-radius: 6px;
  }
  .reload{
    position: absolute;
    bottom: 0;
    left: 160px;
  }
  .search-line{
    margin-bottom: 10px;
    padding: 10px;
    background: white;
  }
  .filter-wraper{
    display: flex;
    justify-content: space-between;
  }
  .table-container /deep/ .el-table .cell{
    display:flex;
  }
</style>
